﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace Sencha.Direct
{
    public abstract partial class Router
    {
        [DataContract]
        public class OutgoingResponse
        {
            public OutgoingResponse(IncomingRequest request, object result, JsError error)
            {
                this.Type = request.Type;
                this.TransactionId = request.TransactionId;
                this.Action = request.Controller;
                this.Method = request.Action;
                this.Result = result;
				this.Error = error;
                this.IsUpload = request.IsUpload;
            }

			[DataMember(Name = "type", Order=2)]
            public string Type
            {
                get;
                set;
            }

            [DataMember(Name = "tid", Order=1)]
            public int TransactionId
            {
                get;
                set;
            }

			[DataMember(Name = "action", Order = 4)]
            public string Action
            {
                get;
                set;
            }

			[DataMember(Name = "method", Order = 3)]
            public string Method
            {
                get;
                set;
            }

			[DataMember(Name="error", Order=5)]
			public JsError Error { get; set; }

            [DataMember(Name = "result", Order=6)]
            public object Result
            {
                get;
                set;
            }

            [IgnoreDataMember]
            public bool IsUpload
            {
                get;
                private set;
            }
        }
    }
}